<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
          padding: 100px;
        }
    
        * {
          margin: 0;
        }
    
        body {
          display: block;
        }
      </style>
</head>
<body>
    <div>
        <ul>留言板</ul>
        <ul></ul>
        <textarea placeholder="请编辑您的留言"></textarea>
        <button>发布</button>
        <ul>
        </ul>
      </div>
</body>
</html>
<script>
    var btn = document.querySelector('button')
    var text = document.querySelector('textarea')
    var ul = document.querySelector('ul')
    btn.onclick = function () {
      if (text.value == '') {
        alert('您没有输入内容');
        return false;
      } else {
        var li = document.createElement('li')
        li.innerHTML = text.value;
        ul.insertBefore(li, ul.children[0]);
      }
    }
  </script>